package pers.li.controller.order;

import pers.li.model.VO.OrderDetailVO;
import pers.li.service.OrderService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/order/toPay.action")
public class ToPay extends HttpServlet {
    private final OrderService orderService = new OrderService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int orderId = Integer.parseInt(req.getParameter("orderId"));
        OrderDetailVO orderDetail = orderService.getOrderDetailVOByOrderId(orderId);
        req.setAttribute("orderDetail",orderDetail);
        orderService.payOrder(orderId);
        req.getRequestDispatcher("payOrder.jsp").forward(req,resp);
    }
}
